<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%-- 
    Document   : index
    Created on : 23.01.2014, 11:36:59
    Author     : Gregorius
--%>

<%@page import="org.webshop.backend.dbahif.DBAccess"%>
<%@page import="java.util.LinkedList"%>
<%@page import="org.webshop.backend.data.Product"%>
<%@page import="java.util.ArrayList"%>
<%--<%@page contentType="text/html" pageEncoding="UTF-8"%> --%>
<%
    String user = "hoegra10";
    DBAccess dba = DBAccess.getInstance();
    LinkedList<Product> productlist = new LinkedList<Product>();
    LinkedList<String> restaurants = new LinkedList<String>();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="ShoppingCart.jsp" method="post">
<p align="right">Angemeldet als: <%=user%></p>
<center>
<table>
<% 
    restaurants = dba.getRestaurants();
    out.println("<tr>");
    out.println("<td>Restaurant:<td>");
    out.println("<td><select name = \"restaurant\""+">");
    for(int rid = 0; rid < restaurants.size(); rid++) // verschiedene Restaurants
    {
        out.println("<option name=\""+restaurants.get(rid)+"\">"+restaurants.get(rid)+"</option>");
    }
    out.println("</select></td>");
    out.println("</tr>");
%>
</table>
<table border ="2px">
    <thead>
        <tr>
            
            <td></td>
            <td><center>Name:</center></td>
            <td></td>
            <td><center>Price:</center></td>
            <td><center>Amount:</center></td>
        </tr>
    </thead>
    <tbody>
<%
    productlist = dba.getProducts();
    for(int i = 0; i < productlist.size(); i++) // Anzahl an produkten
    {
        out.println("<tr>");
        out.println("<td><input type=\"checkbox\" name=\""+productlist.get(i).getDesignation()+"\" value=\"ON\" /></td>");//name der Pizza
        out.println("<td>"+productlist.get(i).getDesignation()+"</td>");//name der Pizza
        out.println("<td><img src=\""+productlist.get(i).getUrl()+"\" width=\"200\" height=\"200\"></td>");//url der Pizza
        out.println("<td>"+String.format("%.2f €",productlist.get(i).getPrice())+"</td>");//preis der Pizza
        out.println("<td><select name ="+productlist.get(i).getDesignation()+"_anzahl>");//name der Pizza
        for(int aid = 0; aid < 10; aid++) // Mengenanzahl
        {
            out.println("<option name=\"anzahl\">"+(aid+1)+"</option>");
        }
        out.println("</select></td>");
        out.println("</tr>");
    }
%>
    </tbody>
</table>
<input type="submit" value="cancel" />
<input type="submit" value="order"/>
</center>
</form>
<%-- <form  action="orderlist" method="post"> --%>
<%
    if(user == "hoegra10")
    {
        out.println("<input type=\"submit\" value=\"Incoming Orders\" name=\"orderlist\"/>");
    }
%>
<%-- </form> --%>
<%-- <form action="orderlistCE" method="post"> --%>
<input type="submit" value="Outgoing Orders" name="orderlistCE"/>
<%-- </form>--%>
</body>
</html>
